// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gax;
extern crate gaxi;
extern crate lazy_static;
extern crate location;
extern crate reqwest;
extern crate rpc;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// A parameter used to define custom fields in a data source definition.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DataSourceParameter {
    /// Parameter identifier.
    pub param_id: std::string::String,

    /// Parameter display name in the user interface.
    pub display_name: std::string::String,

    /// Parameter description.
    pub description: std::string::String,

    /// Parameter type.
    pub r#type: crate::model::data_source_parameter::Type,

    /// Is parameter required.
    pub required: bool,

    /// Deprecated. This field has no effect.
    pub repeated: bool,

    /// Regular expression which can be used for parameter validation.
    pub validation_regex: std::string::String,

    /// All possible values for the parameter.
    pub allowed_values: std::vec::Vec<std::string::String>,

    /// For integer and double values specifies minimum allowed value.
    pub min_value: std::option::Option<wkt::DoubleValue>,

    /// For integer and double values specifies maximum allowed value.
    pub max_value: std::option::Option<wkt::DoubleValue>,

    /// Deprecated. This field has no effect.
    pub fields: std::vec::Vec<crate::model::DataSourceParameter>,

    /// Description of the requirements for this field, in case the user input does
    /// not fulfill the regex pattern or min/max values.
    pub validation_description: std::string::String,

    /// URL to a help document to further explain the naming requirements.
    pub validation_help_url: std::string::String,

    /// Cannot be changed after initial creation.
    pub immutable: bool,

    /// Deprecated. This field has no effect.
    pub recurse: bool,

    /// If true, it should not be used in new transfers, and it should not be
    /// visible to users.
    pub deprecated: bool,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DataSourceParameter {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [param_id][crate::model::DataSourceParameter::param_id].
    pub fn set_param_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.param_id = v.into();
        self
    }

    /// Sets the value of [display_name][crate::model::DataSourceParameter::display_name].
    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.display_name = v.into();
        self
    }

    /// Sets the value of [description][crate::model::DataSourceParameter::description].
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }

    /// Sets the value of [r#type][crate::model::DataSourceParameter::type].
    pub fn set_type<T: std::convert::Into<crate::model::data_source_parameter::Type>>(
        mut self,
        v: T,
    ) -> Self {
        self.r#type = v.into();
        self
    }

    /// Sets the value of [required][crate::model::DataSourceParameter::required].
    pub fn set_required<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.required = v.into();
        self
    }

    /// Sets the value of [repeated][crate::model::DataSourceParameter::repeated].
    pub fn set_repeated<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.repeated = v.into();
        self
    }

    /// Sets the value of [validation_regex][crate::model::DataSourceParameter::validation_regex].
    pub fn set_validation_regex<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.validation_regex = v.into();
        self
    }

    /// Sets the value of [allowed_values][crate::model::DataSourceParameter::allowed_values].
    pub fn set_allowed_values<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.allowed_values = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [min_value][crate::model::DataSourceParameter::min_value].
    pub fn set_min_value<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::DoubleValue>,
    {
        self.min_value = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [min_value][crate::model::DataSourceParameter::min_value].
    pub fn set_or_clear_min_value<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::DoubleValue>,
    {
        self.min_value = v.map(|x| x.into());
        self
    }

    /// Sets the value of [max_value][crate::model::DataSourceParameter::max_value].
    pub fn set_max_value<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::DoubleValue>,
    {
        self.max_value = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [max_value][crate::model::DataSourceParameter::max_value].
    pub fn set_or_clear_max_value<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::DoubleValue>,
    {
        self.max_value = v.map(|x| x.into());
        self
    }

    /// Sets the value of [fields][crate::model::DataSourceParameter::fields].
    pub fn set_fields<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::DataSourceParameter>,
    {
        use std::iter::Iterator;
        self.fields = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [validation_description][crate::model::DataSourceParameter::validation_description].
    pub fn set_validation_description<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.validation_description = v.into();
        self
    }

    /// Sets the value of [validation_help_url][crate::model::DataSourceParameter::validation_help_url].
    pub fn set_validation_help_url<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.validation_help_url = v.into();
        self
    }

    /// Sets the value of [immutable][crate::model::DataSourceParameter::immutable].
    pub fn set_immutable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.immutable = v.into();
        self
    }

    /// Sets the value of [recurse][crate::model::DataSourceParameter::recurse].
    pub fn set_recurse<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.recurse = v.into();
        self
    }

    /// Sets the value of [deprecated][crate::model::DataSourceParameter::deprecated].
    pub fn set_deprecated<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.deprecated = v.into();
        self
    }
}

impl wkt::message::Message for DataSourceParameter {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.DataSourceParameter"
    }
}

/// Defines additional types related to [DataSourceParameter].
pub mod data_source_parameter {
    #[allow(unused_imports)]
    use super::*;

    /// Parameter type.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Type {
        /// Type unspecified.
        Unspecified,
        /// String parameter.
        String,
        /// Integer parameter (64-bits).
        /// Will be serialized to json as string.
        Integer,
        /// Double precision floating point parameter.
        Double,
        /// Boolean parameter.
        Boolean,
        /// Deprecated. This field has no effect.
        Record,
        /// Page ID for a Google+ Page.
        PlusPage,
        /// List of strings parameter.
        List,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [Type::value] or
        /// [Type::name].
        UnknownValue(r#type::UnknownValue),
    }

    #[doc(hidden)]
    pub mod r#type {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl Type {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::String => std::option::Option::Some(1),
                Self::Integer => std::option::Option::Some(2),
                Self::Double => std::option::Option::Some(3),
                Self::Boolean => std::option::Option::Some(4),
                Self::Record => std::option::Option::Some(5),
                Self::PlusPage => std::option::Option::Some(6),
                Self::List => std::option::Option::Some(7),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
                Self::String => std::option::Option::Some("STRING"),
                Self::Integer => std::option::Option::Some("INTEGER"),
                Self::Double => std::option::Option::Some("DOUBLE"),
                Self::Boolean => std::option::Option::Some("BOOLEAN"),
                Self::Record => std::option::Option::Some("RECORD"),
                Self::PlusPage => std::option::Option::Some("PLUS_PAGE"),
                Self::List => std::option::Option::Some("LIST"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for Type {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for Type {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for Type {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::String,
                2 => Self::Integer,
                3 => Self::Double,
                4 => Self::Boolean,
                5 => Self::Record,
                6 => Self::PlusPage,
                7 => Self::List,
                _ => Self::UnknownValue(r#type::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for Type {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "TYPE_UNSPECIFIED" => Self::Unspecified,
                "STRING" => Self::String,
                "INTEGER" => Self::Integer,
                "DOUBLE" => Self::Double,
                "BOOLEAN" => Self::Boolean,
                "RECORD" => Self::Record,
                "PLUS_PAGE" => Self::PlusPage,
                "LIST" => Self::List,
                _ => Self::UnknownValue(r#type::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for Type {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::String => serializer.serialize_i32(1),
                Self::Integer => serializer.serialize_i32(2),
                Self::Double => serializer.serialize_i32(3),
                Self::Boolean => serializer.serialize_i32(4),
                Self::Record => serializer.serialize_i32(5),
                Self::PlusPage => serializer.serialize_i32(6),
                Self::List => serializer.serialize_i32(7),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for Type {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
                ".google.cloud.bigquery.datatransfer.v1.DataSourceParameter.Type",
            ))
        }
    }
}

/// Defines the properties and custom parameters for a data source.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DataSource {
    /// Output only. Data source resource name.
    pub name: std::string::String,

    /// Data source id.
    pub data_source_id: std::string::String,

    /// User friendly data source name.
    pub display_name: std::string::String,

    /// User friendly data source description string.
    pub description: std::string::String,

    /// Data source client id which should be used to receive refresh token.
    pub client_id: std::string::String,

    /// Api auth scopes for which refresh token needs to be obtained. These are
    /// scopes needed by a data source to prepare data and ingest them into
    /// BigQuery, e.g., <https://www.googleapis.com/auth/bigquery>
    pub scopes: std::vec::Vec<std::string::String>,

    /// Deprecated. This field has no effect.
    #[deprecated]
    pub transfer_type: crate::model::TransferType,

    /// Deprecated. This field has no effect.
    #[deprecated]
    pub supports_multiple_transfers: bool,

    /// The number of seconds to wait for an update from the data source
    /// before the Data Transfer Service marks the transfer as FAILED.
    pub update_deadline_seconds: i32,

    /// Default data transfer schedule.
    /// Examples of valid schedules include:
    /// `1st,3rd monday of month 15:30`,
    /// `every wed,fri of jan,jun 13:15`, and
    /// `first sunday of quarter 00:00`.
    pub default_schedule: std::string::String,

    /// Specifies whether the data source supports a user defined schedule, or
    /// operates on the default schedule.
    /// When set to `true`, user can override default schedule.
    pub supports_custom_schedule: bool,

    /// Data source parameters.
    pub parameters: std::vec::Vec<crate::model::DataSourceParameter>,

    /// Url for the help document for this data source.
    pub help_url: std::string::String,

    /// Indicates the type of authorization.
    pub authorization_type: crate::model::data_source::AuthorizationType,

    /// Specifies whether the data source supports automatic data refresh for the
    /// past few days, and how it's supported.
    /// For some data sources, data might not be complete until a few days later,
    /// so it's useful to refresh data automatically.
    pub data_refresh_type: crate::model::data_source::DataRefreshType,

    /// Default data refresh window on days.
    /// Only meaningful when `data_refresh_type` = `SLIDING_WINDOW`.
    pub default_data_refresh_window_days: i32,

    /// Disables backfilling and manual run scheduling
    /// for the data source.
    pub manual_runs_disabled: bool,

    /// The minimum interval for scheduler to schedule runs.
    pub minimum_schedule_interval: std::option::Option<wkt::Duration>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DataSource {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::DataSource::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [data_source_id][crate::model::DataSource::data_source_id].
    pub fn set_data_source_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.data_source_id = v.into();
        self
    }

    /// Sets the value of [display_name][crate::model::DataSource::display_name].
    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.display_name = v.into();
        self
    }

    /// Sets the value of [description][crate::model::DataSource::description].
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }

    /// Sets the value of [client_id][crate::model::DataSource::client_id].
    pub fn set_client_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.client_id = v.into();
        self
    }

    /// Sets the value of [scopes][crate::model::DataSource::scopes].
    pub fn set_scopes<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.scopes = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [transfer_type][crate::model::DataSource::transfer_type].
    #[deprecated]
    pub fn set_transfer_type<T: std::convert::Into<crate::model::TransferType>>(
        mut self,
        v: T,
    ) -> Self {
        self.transfer_type = v.into();
        self
    }

    /// Sets the value of [supports_multiple_transfers][crate::model::DataSource::supports_multiple_transfers].
    #[deprecated]
    pub fn set_supports_multiple_transfers<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.supports_multiple_transfers = v.into();
        self
    }

    /// Sets the value of [update_deadline_seconds][crate::model::DataSource::update_deadline_seconds].
    pub fn set_update_deadline_seconds<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.update_deadline_seconds = v.into();
        self
    }

    /// Sets the value of [default_schedule][crate::model::DataSource::default_schedule].
    pub fn set_default_schedule<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.default_schedule = v.into();
        self
    }

    /// Sets the value of [supports_custom_schedule][crate::model::DataSource::supports_custom_schedule].
    pub fn set_supports_custom_schedule<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.supports_custom_schedule = v.into();
        self
    }

    /// Sets the value of [parameters][crate::model::DataSource::parameters].
    pub fn set_parameters<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::DataSourceParameter>,
    {
        use std::iter::Iterator;
        self.parameters = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [help_url][crate::model::DataSource::help_url].
    pub fn set_help_url<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.help_url = v.into();
        self
    }

    /// Sets the value of [authorization_type][crate::model::DataSource::authorization_type].
    pub fn set_authorization_type<
        T: std::convert::Into<crate::model::data_source::AuthorizationType>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.authorization_type = v.into();
        self
    }

    /// Sets the value of [data_refresh_type][crate::model::DataSource::data_refresh_type].
    pub fn set_data_refresh_type<
        T: std::convert::Into<crate::model::data_source::DataRefreshType>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.data_refresh_type = v.into();
        self
    }

    /// Sets the value of [default_data_refresh_window_days][crate::model::DataSource::default_data_refresh_window_days].
    pub fn set_default_data_refresh_window_days<T: std::convert::Into<i32>>(
        mut self,
        v: T,
    ) -> Self {
        self.default_data_refresh_window_days = v.into();
        self
    }

    /// Sets the value of [manual_runs_disabled][crate::model::DataSource::manual_runs_disabled].
    pub fn set_manual_runs_disabled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.manual_runs_disabled = v.into();
        self
    }

    /// Sets the value of [minimum_schedule_interval][crate::model::DataSource::minimum_schedule_interval].
    pub fn set_minimum_schedule_interval<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Duration>,
    {
        self.minimum_schedule_interval = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [minimum_schedule_interval][crate::model::DataSource::minimum_schedule_interval].
    pub fn set_or_clear_minimum_schedule_interval<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Duration>,
    {
        self.minimum_schedule_interval = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for DataSource {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.DataSource"
    }
}

/// Defines additional types related to [DataSource].
pub mod data_source {
    #[allow(unused_imports)]
    use super::*;

    /// The type of authorization needed for this data source.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum AuthorizationType {
        /// Type unspecified.
        Unspecified,
        /// Use OAuth 2 authorization codes that can be exchanged
        /// for a refresh token on the backend.
        AuthorizationCode,
        /// Return an authorization code for a given Google+ page that can then be
        /// exchanged for a refresh token on the backend.
        GooglePlusAuthorizationCode,
        /// Use First Party OAuth.
        FirstPartyOauth,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [AuthorizationType::value] or
        /// [AuthorizationType::name].
        UnknownValue(authorization_type::UnknownValue),
    }

    #[doc(hidden)]
    pub mod authorization_type {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl AuthorizationType {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::AuthorizationCode => std::option::Option::Some(1),
                Self::GooglePlusAuthorizationCode => std::option::Option::Some(2),
                Self::FirstPartyOauth => std::option::Option::Some(3),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("AUTHORIZATION_TYPE_UNSPECIFIED"),
                Self::AuthorizationCode => std::option::Option::Some("AUTHORIZATION_CODE"),
                Self::GooglePlusAuthorizationCode => {
                    std::option::Option::Some("GOOGLE_PLUS_AUTHORIZATION_CODE")
                }
                Self::FirstPartyOauth => std::option::Option::Some("FIRST_PARTY_OAUTH"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for AuthorizationType {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for AuthorizationType {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for AuthorizationType {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::AuthorizationCode,
                2 => Self::GooglePlusAuthorizationCode,
                3 => Self::FirstPartyOauth,
                _ => Self::UnknownValue(authorization_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for AuthorizationType {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "AUTHORIZATION_TYPE_UNSPECIFIED" => Self::Unspecified,
                "AUTHORIZATION_CODE" => Self::AuthorizationCode,
                "GOOGLE_PLUS_AUTHORIZATION_CODE" => Self::GooglePlusAuthorizationCode,
                "FIRST_PARTY_OAUTH" => Self::FirstPartyOauth,
                _ => Self::UnknownValue(authorization_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for AuthorizationType {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::AuthorizationCode => serializer.serialize_i32(1),
                Self::GooglePlusAuthorizationCode => serializer.serialize_i32(2),
                Self::FirstPartyOauth => serializer.serialize_i32(3),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for AuthorizationType {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<AuthorizationType>::new(
                ".google.cloud.bigquery.datatransfer.v1.DataSource.AuthorizationType",
            ))
        }
    }

    /// Represents how the data source supports data auto refresh.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum DataRefreshType {
        /// The data source won't support data auto refresh, which is default value.
        Unspecified,
        /// The data source supports data auto refresh, and runs will be scheduled
        /// for the past few days. Does not allow custom values to be set for each
        /// transfer config.
        SlidingWindow,
        /// The data source supports data auto refresh, and runs will be scheduled
        /// for the past few days. Allows custom values to be set for each transfer
        /// config.
        CustomSlidingWindow,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [DataRefreshType::value] or
        /// [DataRefreshType::name].
        UnknownValue(data_refresh_type::UnknownValue),
    }

    #[doc(hidden)]
    pub mod data_refresh_type {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl DataRefreshType {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::SlidingWindow => std::option::Option::Some(1),
                Self::CustomSlidingWindow => std::option::Option::Some(2),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("DATA_REFRESH_TYPE_UNSPECIFIED"),
                Self::SlidingWindow => std::option::Option::Some("SLIDING_WINDOW"),
                Self::CustomSlidingWindow => std::option::Option::Some("CUSTOM_SLIDING_WINDOW"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for DataRefreshType {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for DataRefreshType {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for DataRefreshType {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::SlidingWindow,
                2 => Self::CustomSlidingWindow,
                _ => Self::UnknownValue(data_refresh_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for DataRefreshType {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "DATA_REFRESH_TYPE_UNSPECIFIED" => Self::Unspecified,
                "SLIDING_WINDOW" => Self::SlidingWindow,
                "CUSTOM_SLIDING_WINDOW" => Self::CustomSlidingWindow,
                _ => Self::UnknownValue(data_refresh_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for DataRefreshType {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::SlidingWindow => serializer.serialize_i32(1),
                Self::CustomSlidingWindow => serializer.serialize_i32(2),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for DataRefreshType {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<DataRefreshType>::new(
                ".google.cloud.bigquery.datatransfer.v1.DataSource.DataRefreshType",
            ))
        }
    }
}

/// A request to get data source info.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetDataSourceRequest {
    /// Required. The field will contain name of the resource requested, for
    /// example: `projects/{project_id}/dataSources/{data_source_id}` or
    /// `projects/{project_id}/locations/{location_id}/dataSources/{data_source_id}`
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetDataSourceRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetDataSourceRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetDataSourceRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.GetDataSourceRequest"
    }
}

/// Request to list supported data sources and their data transfer settings.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListDataSourcesRequest {
    /// Required. The BigQuery project id for which data sources should be
    /// returned. Must be in the form: `projects/{project_id}` or
    /// `projects/{project_id}/locations/{location_id}`
    pub parent: std::string::String,

    /// Pagination token, which can be used to request a specific page
    /// of `ListDataSourcesRequest` list results. For multiple-page
    /// results, `ListDataSourcesResponse` outputs
    /// a `next_page` token, which can be used as the
    /// `page_token` value to request the next page of list results.
    pub page_token: std::string::String,

    /// Page size. The default page size is the maximum value of 1000 results.
    pub page_size: i32,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListDataSourcesRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListDataSourcesRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListDataSourcesRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListDataSourcesRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }
}

impl wkt::message::Message for ListDataSourcesRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.ListDataSourcesRequest"
    }
}

/// Returns list of supported data sources and their metadata.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListDataSourcesResponse {
    /// List of supported data sources and their transfer settings.
    pub data_sources: std::vec::Vec<crate::model::DataSource>,

    /// Output only. The next-pagination token. For multiple-page list results,
    /// this token can be used as the
    /// `ListDataSourcesRequest.page_token`
    /// to request the next page of list results.
    pub next_page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListDataSourcesResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [data_sources][crate::model::ListDataSourcesResponse::data_sources].
    pub fn set_data_sources<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::DataSource>,
    {
        use std::iter::Iterator;
        self.data_sources = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListDataSourcesResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListDataSourcesResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.ListDataSourcesResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListDataSourcesResponse {
    type PageItem = crate::model::DataSource;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.data_sources
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// A request to create a data transfer configuration. If new credentials are
/// needed for this transfer configuration, authorization info must be provided.
/// If authorization info is provided, the transfer configuration will be
/// associated with the user id corresponding to the authorization info.
/// Otherwise, the transfer configuration will be associated with the calling
/// user.
///
/// When using a cross project service account for creating a transfer config,
/// you must enable cross project service account usage. For more information,
/// see [Disable attachment of service accounts to resources in other
/// projects](https://cloud.google.com/resource-manager/docs/organization-policy/restricting-service-accounts#disable_cross_project_service_accounts).
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateTransferConfigRequest {
    /// Required. The BigQuery project id where the transfer configuration should
    /// be created. Must be in the format
    /// projects/{project_id}/locations/{location_id} or projects/{project_id}. If
    /// specified location and location of the destination bigquery dataset do not
    /// match - the request will fail.
    pub parent: std::string::String,

    /// Required. Data transfer configuration to create.
    pub transfer_config: std::option::Option<crate::model::TransferConfig>,

    /// Deprecated: Authorization code was required when
    /// `transferConfig.dataSourceId` is 'youtube_channel' but it is no longer used
    /// in any data sources. Use `version_info` instead.
    ///
    /// Optional OAuth2 authorization code to use with this transfer configuration.
    /// This is required only if `transferConfig.dataSourceId` is 'youtube_channel'
    /// and new credentials are needed, as indicated by `CheckValidCreds`. In order
    /// to obtain authorization_code, make a request to the following URL:
    ///
    /// * The \<var\>client_id\</var\> is the OAuth client_id of the data source as
    ///   returned by ListDataSources method.
    /// * \<var\>data_source_scopes\</var\> are the scopes returned by ListDataSources
    ///   method.
    ///
    /// Note that this should not be set when `service_account_name` is used to
    /// create the transfer config.
    #[deprecated]
    pub authorization_code: std::string::String,

    /// Optional version info. This parameter replaces `authorization_code` which
    /// is no longer used in any data sources. This is required only if
    /// `transferConfig.dataSourceId` is 'youtube_channel' *or* new credentials
    /// are needed, as indicated by `CheckValidCreds`. In order to obtain version
    /// info, make a request to the following URL:
    ///
    /// * The \<var\>client_id\</var\> is the OAuth client_id of the data source as
    ///   returned by ListDataSources method.
    /// * \<var\>data_source_scopes\</var\> are the scopes returned by ListDataSources
    ///   method.
    ///
    /// Note that this should not be set when `service_account_name` is used to
    /// create the transfer config.
    pub version_info: std::string::String,

    /// Optional service account email. If this field is set, the transfer config
    /// will be created with this service account's credentials. It requires that
    /// the requesting user calling this API has permissions to act as this service
    /// account.
    ///
    /// Note that not all data sources support service account credentials when
    /// creating a transfer config. For the latest list of data sources, read about
    /// [using service
    /// accounts](https://cloud.google.com/bigquery-transfer/docs/use-service-accounts).
    pub service_account_name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateTransferConfigRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreateTransferConfigRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [transfer_config][crate::model::CreateTransferConfigRequest::transfer_config].
    pub fn set_transfer_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::TransferConfig>,
    {
        self.transfer_config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [transfer_config][crate::model::CreateTransferConfigRequest::transfer_config].
    pub fn set_or_clear_transfer_config<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::TransferConfig>,
    {
        self.transfer_config = v.map(|x| x.into());
        self
    }

    /// Sets the value of [authorization_code][crate::model::CreateTransferConfigRequest::authorization_code].
    #[deprecated]
    pub fn set_authorization_code<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.authorization_code = v.into();
        self
    }

    /// Sets the value of [version_info][crate::model::CreateTransferConfigRequest::version_info].
    pub fn set_version_info<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.version_info = v.into();
        self
    }

    /// Sets the value of [service_account_name][crate::model::CreateTransferConfigRequest::service_account_name].
    pub fn set_service_account_name<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.service_account_name = v.into();
        self
    }
}

impl wkt::message::Message for CreateTransferConfigRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.CreateTransferConfigRequest"
    }
}

/// A request to update a transfer configuration. To update the user id of the
/// transfer configuration, authorization info needs to be provided.
///
/// When using a cross project service account for updating a transfer config,
/// you must enable cross project service account usage. For more information,
/// see [Disable attachment of service accounts to resources in other
/// projects](https://cloud.google.com/resource-manager/docs/organization-policy/restricting-service-accounts#disable_cross_project_service_accounts).
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UpdateTransferConfigRequest {
    /// Required. Data transfer configuration to create.
    pub transfer_config: std::option::Option<crate::model::TransferConfig>,

    /// Deprecated: Authorization code was required when
    /// `transferConfig.dataSourceId` is 'youtube_channel' but it is no longer used
    /// in any data sources. Use `version_info` instead.
    ///
    /// Optional OAuth2 authorization code to use with this transfer configuration.
    /// This is required only if `transferConfig.dataSourceId` is 'youtube_channel'
    /// and new credentials are needed, as indicated by `CheckValidCreds`. In order
    /// to obtain authorization_code, make a request to the following URL:
    ///
    /// * The \<var\>client_id\</var\> is the OAuth client_id of the data source as
    ///   returned by ListDataSources method.
    /// * \<var\>data_source_scopes\</var\> are the scopes returned by ListDataSources
    ///   method.
    ///
    /// Note that this should not be set when `service_account_name` is used to
    /// update the transfer config.
    #[deprecated]
    pub authorization_code: std::string::String,

    /// Required. Required list of fields to be updated in this request.
    pub update_mask: std::option::Option<wkt::FieldMask>,

    /// Optional version info. This parameter replaces `authorization_code` which
    /// is no longer used in any data sources. This is required only if
    /// `transferConfig.dataSourceId` is 'youtube_channel' *or* new credentials
    /// are needed, as indicated by `CheckValidCreds`. In order to obtain version
    /// info, make a request to the following URL:
    ///
    /// * The \<var\>client_id\</var\> is the OAuth client_id of the data source as
    ///   returned by ListDataSources method.
    /// * \<var\>data_source_scopes\</var\> are the scopes returned by ListDataSources
    ///   method.
    ///
    /// Note that this should not be set when `service_account_name` is used to
    /// update the transfer config.
    pub version_info: std::string::String,

    /// Optional service account email. If this field is set, the transfer config
    /// will be created with this service account's credentials. It requires that
    /// the requesting user calling this API has permissions to act as this service
    /// account.
    ///
    /// Note that not all data sources support service account credentials when
    /// creating a transfer config. For the latest list of data sources, read about
    /// [using service
    /// accounts](https://cloud.google.com/bigquery-transfer/docs/use-service-accounts).
    pub service_account_name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UpdateTransferConfigRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [transfer_config][crate::model::UpdateTransferConfigRequest::transfer_config].
    pub fn set_transfer_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::TransferConfig>,
    {
        self.transfer_config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [transfer_config][crate::model::UpdateTransferConfigRequest::transfer_config].
    pub fn set_or_clear_transfer_config<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::TransferConfig>,
    {
        self.transfer_config = v.map(|x| x.into());
        self
    }

    /// Sets the value of [authorization_code][crate::model::UpdateTransferConfigRequest::authorization_code].
    #[deprecated]
    pub fn set_authorization_code<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.authorization_code = v.into();
        self
    }

    /// Sets the value of [update_mask][crate::model::UpdateTransferConfigRequest::update_mask].
    pub fn set_update_mask<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_mask][crate::model::UpdateTransferConfigRequest::update_mask].
    pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = v.map(|x| x.into());
        self
    }

    /// Sets the value of [version_info][crate::model::UpdateTransferConfigRequest::version_info].
    pub fn set_version_info<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.version_info = v.into();
        self
    }

    /// Sets the value of [service_account_name][crate::model::UpdateTransferConfigRequest::service_account_name].
    pub fn set_service_account_name<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.service_account_name = v.into();
        self
    }
}

impl wkt::message::Message for UpdateTransferConfigRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.UpdateTransferConfigRequest"
    }
}

/// A request to get data transfer information.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetTransferConfigRequest {
    /// Required. The field will contain name of the resource requested, for
    /// example: `projects/{project_id}/transferConfigs/{config_id}` or
    /// `projects/{project_id}/locations/{location_id}/transferConfigs/{config_id}`
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetTransferConfigRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetTransferConfigRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetTransferConfigRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.GetTransferConfigRequest"
    }
}

/// A request to delete data transfer information. All associated transfer runs
/// and log messages will be deleted as well.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DeleteTransferConfigRequest {
    /// Required. The field will contain name of the resource requested, for
    /// example: `projects/{project_id}/transferConfigs/{config_id}` or
    /// `projects/{project_id}/locations/{location_id}/transferConfigs/{config_id}`
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DeleteTransferConfigRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::DeleteTransferConfigRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for DeleteTransferConfigRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.DeleteTransferConfigRequest"
    }
}

/// A request to get data transfer run information.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetTransferRunRequest {
    /// Required. The field will contain name of the resource requested, for
    /// example: `projects/{project_id}/transferConfigs/{config_id}/runs/{run_id}`
    /// or
    /// `projects/{project_id}/locations/{location_id}/transferConfigs/{config_id}/runs/{run_id}`
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetTransferRunRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetTransferRunRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetTransferRunRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.GetTransferRunRequest"
    }
}

/// A request to delete data transfer run information.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DeleteTransferRunRequest {
    /// Required. The field will contain name of the resource requested, for
    /// example: `projects/{project_id}/transferConfigs/{config_id}/runs/{run_id}`
    /// or
    /// `projects/{project_id}/locations/{location_id}/transferConfigs/{config_id}/runs/{run_id}`
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DeleteTransferRunRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::DeleteTransferRunRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for DeleteTransferRunRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.DeleteTransferRunRequest"
    }
}

/// A request to list data transfers configured for a BigQuery project.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListTransferConfigsRequest {
    /// Required. The BigQuery project id for which transfer configs
    /// should be returned: `projects/{project_id}` or
    /// `projects/{project_id}/locations/{location_id}`
    pub parent: std::string::String,

    /// When specified, only configurations of requested data sources are returned.
    pub data_source_ids: std::vec::Vec<std::string::String>,

    /// Pagination token, which can be used to request a specific page
    /// of `ListTransfersRequest` list results. For multiple-page
    /// results, `ListTransfersResponse` outputs
    /// a `next_page` token, which can be used as the
    /// `page_token` value to request the next page of list results.
    pub page_token: std::string::String,

    /// Page size. The default page size is the maximum value of 1000 results.
    pub page_size: i32,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListTransferConfigsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListTransferConfigsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [data_source_ids][crate::model::ListTransferConfigsRequest::data_source_ids].
    pub fn set_data_source_ids<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.data_source_ids = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [page_token][crate::model::ListTransferConfigsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListTransferConfigsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }
}

impl wkt::message::Message for ListTransferConfigsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.ListTransferConfigsRequest"
    }
}

/// The returned list of pipelines in the project.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListTransferConfigsResponse {
    /// Output only. The stored pipeline transfer configurations.
    pub transfer_configs: std::vec::Vec<crate::model::TransferConfig>,

    /// Output only. The next-pagination token. For multiple-page list results,
    /// this token can be used as the
    /// `ListTransferConfigsRequest.page_token`
    /// to request the next page of list results.
    pub next_page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListTransferConfigsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [transfer_configs][crate::model::ListTransferConfigsResponse::transfer_configs].
    pub fn set_transfer_configs<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::TransferConfig>,
    {
        use std::iter::Iterator;
        self.transfer_configs = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListTransferConfigsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListTransferConfigsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.ListTransferConfigsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListTransferConfigsResponse {
    type PageItem = crate::model::TransferConfig;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.transfer_configs
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// A request to list data transfer runs.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListTransferRunsRequest {
    /// Required. Name of transfer configuration for which transfer runs should be
    /// retrieved. Format of transfer configuration resource name is:
    /// `projects/{project_id}/transferConfigs/{config_id}` or
    /// `projects/{project_id}/locations/{location_id}/transferConfigs/{config_id}`.
    pub parent: std::string::String,

    /// When specified, only transfer runs with requested states are returned.
    pub states: std::vec::Vec<crate::model::TransferState>,

    /// Pagination token, which can be used to request a specific page
    /// of `ListTransferRunsRequest` list results. For multiple-page
    /// results, `ListTransferRunsResponse` outputs
    /// a `next_page` token, which can be used as the
    /// `page_token` value to request the next page of list results.
    pub page_token: std::string::String,

    /// Page size. The default page size is the maximum value of 1000 results.
    pub page_size: i32,

    /// Indicates how run attempts are to be pulled.
    pub run_attempt: crate::model::list_transfer_runs_request::RunAttempt,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListTransferRunsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListTransferRunsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [states][crate::model::ListTransferRunsRequest::states].
    pub fn set_states<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::TransferState>,
    {
        use std::iter::Iterator;
        self.states = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [page_token][crate::model::ListTransferRunsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListTransferRunsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [run_attempt][crate::model::ListTransferRunsRequest::run_attempt].
    pub fn set_run_attempt<
        T: std::convert::Into<crate::model::list_transfer_runs_request::RunAttempt>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.run_attempt = v.into();
        self
    }
}

impl wkt::message::Message for ListTransferRunsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.ListTransferRunsRequest"
    }
}

/// Defines additional types related to [ListTransferRunsRequest].
pub mod list_transfer_runs_request {
    #[allow(unused_imports)]
    use super::*;

    /// Represents which runs should be pulled.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum RunAttempt {
        /// All runs should be returned.
        Unspecified,
        /// Only latest run per day should be returned.
        Latest,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [RunAttempt::value] or
        /// [RunAttempt::name].
        UnknownValue(run_attempt::UnknownValue),
    }

    #[doc(hidden)]
    pub mod run_attempt {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl RunAttempt {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Latest => std::option::Option::Some(1),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("RUN_ATTEMPT_UNSPECIFIED"),
                Self::Latest => std::option::Option::Some("LATEST"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for RunAttempt {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for RunAttempt {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for RunAttempt {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Latest,
                _ => Self::UnknownValue(run_attempt::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for RunAttempt {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "RUN_ATTEMPT_UNSPECIFIED" => Self::Unspecified,
                "LATEST" => Self::Latest,
                _ => Self::UnknownValue(run_attempt::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for RunAttempt {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Latest => serializer.serialize_i32(1),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for RunAttempt {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<RunAttempt>::new(
                ".google.cloud.bigquery.datatransfer.v1.ListTransferRunsRequest.RunAttempt",
            ))
        }
    }
}

/// The returned list of pipelines in the project.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListTransferRunsResponse {
    /// Output only. The stored pipeline transfer runs.
    pub transfer_runs: std::vec::Vec<crate::model::TransferRun>,

    /// Output only. The next-pagination token. For multiple-page list results,
    /// this token can be used as the
    /// `ListTransferRunsRequest.page_token`
    /// to request the next page of list results.
    pub next_page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListTransferRunsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [transfer_runs][crate::model::ListTransferRunsResponse::transfer_runs].
    pub fn set_transfer_runs<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::TransferRun>,
    {
        use std::iter::Iterator;
        self.transfer_runs = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListTransferRunsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListTransferRunsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.ListTransferRunsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListTransferRunsResponse {
    type PageItem = crate::model::TransferRun;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.transfer_runs
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// A request to get user facing log messages associated with data transfer run.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListTransferLogsRequest {
    /// Required. Transfer run name in the form:
    /// `projects/{project_id}/transferConfigs/{config_id}/runs/{run_id}` or
    /// `projects/{project_id}/locations/{location_id}/transferConfigs/{config_id}/runs/{run_id}`
    pub parent: std::string::String,

    /// Pagination token, which can be used to request a specific page
    /// of `ListTransferLogsRequest` list results. For multiple-page
    /// results, `ListTransferLogsResponse` outputs
    /// a `next_page` token, which can be used as the
    /// `page_token` value to request the next page of list results.
    pub page_token: std::string::String,

    /// Page size. The default page size is the maximum value of 1000 results.
    pub page_size: i32,

    /// Message types to return. If not populated - INFO, WARNING and ERROR
    /// messages are returned.
    pub message_types: std::vec::Vec<crate::model::transfer_message::MessageSeverity>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListTransferLogsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListTransferLogsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListTransferLogsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListTransferLogsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [message_types][crate::model::ListTransferLogsRequest::message_types].
    pub fn set_message_types<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::transfer_message::MessageSeverity>,
    {
        use std::iter::Iterator;
        self.message_types = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ListTransferLogsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.ListTransferLogsRequest"
    }
}

/// The returned list transfer run messages.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListTransferLogsResponse {
    /// Output only. The stored pipeline transfer messages.
    pub transfer_messages: std::vec::Vec<crate::model::TransferMessage>,

    /// Output only. The next-pagination token. For multiple-page list results,
    /// this token can be used as the
    /// `GetTransferRunLogRequest.page_token`
    /// to request the next page of list results.
    pub next_page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListTransferLogsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [transfer_messages][crate::model::ListTransferLogsResponse::transfer_messages].
    pub fn set_transfer_messages<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::TransferMessage>,
    {
        use std::iter::Iterator;
        self.transfer_messages = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListTransferLogsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListTransferLogsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.ListTransferLogsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListTransferLogsResponse {
    type PageItem = crate::model::TransferMessage;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.transfer_messages
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// A request to determine whether the user has valid credentials. This method
/// is used to limit the number of OAuth popups in the user interface. The
/// user id is inferred from the API call context.
/// If the data source has the Google+ authorization type, this method
/// returns false, as it cannot be determined whether the credentials are
/// already valid merely based on the user id.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CheckValidCredsRequest {
    /// Required. The data source in the form:
    /// `projects/{project_id}/dataSources/{data_source_id}` or
    /// `projects/{project_id}/locations/{location_id}/dataSources/{data_source_id}`.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CheckValidCredsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::CheckValidCredsRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for CheckValidCredsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.CheckValidCredsRequest"
    }
}

/// A response indicating whether the credentials exist and are valid.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CheckValidCredsResponse {
    /// If set to `true`, the credentials exist and are valid.
    pub has_valid_creds: bool,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CheckValidCredsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [has_valid_creds][crate::model::CheckValidCredsResponse::has_valid_creds].
    pub fn set_has_valid_creds<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.has_valid_creds = v.into();
        self
    }
}

impl wkt::message::Message for CheckValidCredsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.CheckValidCredsResponse"
    }
}

/// A request to schedule transfer runs for a time range.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ScheduleTransferRunsRequest {
    /// Required. Transfer configuration name in the form:
    /// `projects/{project_id}/transferConfigs/{config_id}` or
    /// `projects/{project_id}/locations/{location_id}/transferConfigs/{config_id}`.
    pub parent: std::string::String,

    /// Required. Start time of the range of transfer runs. For example,
    /// `"2017-05-25T00:00:00+00:00"`.
    pub start_time: std::option::Option<wkt::Timestamp>,

    /// Required. End time of the range of transfer runs. For example,
    /// `"2017-05-30T00:00:00+00:00"`.
    pub end_time: std::option::Option<wkt::Timestamp>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ScheduleTransferRunsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ScheduleTransferRunsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [start_time][crate::model::ScheduleTransferRunsRequest::start_time].
    pub fn set_start_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.start_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [start_time][crate::model::ScheduleTransferRunsRequest::start_time].
    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.start_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [end_time][crate::model::ScheduleTransferRunsRequest::end_time].
    pub fn set_end_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [end_time][crate::model::ScheduleTransferRunsRequest::end_time].
    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for ScheduleTransferRunsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.ScheduleTransferRunsRequest"
    }
}

/// A response to schedule transfer runs for a time range.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ScheduleTransferRunsResponse {
    /// The transfer runs that were scheduled.
    pub runs: std::vec::Vec<crate::model::TransferRun>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ScheduleTransferRunsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [runs][crate::model::ScheduleTransferRunsResponse::runs].
    pub fn set_runs<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::TransferRun>,
    {
        use std::iter::Iterator;
        self.runs = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ScheduleTransferRunsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.ScheduleTransferRunsResponse"
    }
}

/// A request to start manual transfer runs.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct StartManualTransferRunsRequest {
    /// Required. Transfer configuration name in the form:
    /// `projects/{project_id}/transferConfigs/{config_id}` or
    /// `projects/{project_id}/locations/{location_id}/transferConfigs/{config_id}`.
    pub parent: std::string::String,

    /// The requested time specification - this can be a time range or a specific
    /// run_time.
    pub time: std::option::Option<crate::model::start_manual_transfer_runs_request::Time>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl StartManualTransferRunsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::StartManualTransferRunsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [time][crate::model::StartManualTransferRunsRequest::time].
    ///
    /// Note that all the setters affecting `time` are mutually
    /// exclusive.
    pub fn set_time<
        T: std::convert::Into<
                std::option::Option<crate::model::start_manual_transfer_runs_request::Time>,
            >,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.time = v.into();
        self
    }

    /// The value of [time][crate::model::StartManualTransferRunsRequest::time]
    /// if it holds a `RequestedTimeRange`, `None` if the field is not set or
    /// holds a different branch.
    pub fn requested_time_range(
        &self,
    ) -> std::option::Option<
        &std::boxed::Box<crate::model::start_manual_transfer_runs_request::TimeRange>,
    > {
        #[allow(unreachable_patterns)]
        self.time.as_ref().and_then(|v| match v {
            crate::model::start_manual_transfer_runs_request::Time::RequestedTimeRange(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [time][crate::model::StartManualTransferRunsRequest::time]
    /// to hold a `RequestedTimeRange`.
    ///
    /// Note that all the setters affecting `time` are
    /// mutually exclusive.
    pub fn set_requested_time_range<
        T: std::convert::Into<
                std::boxed::Box<crate::model::start_manual_transfer_runs_request::TimeRange>,
            >,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.time = std::option::Option::Some(
            crate::model::start_manual_transfer_runs_request::Time::RequestedTimeRange(v.into()),
        );
        self
    }

    /// The value of [time][crate::model::StartManualTransferRunsRequest::time]
    /// if it holds a `RequestedRunTime`, `None` if the field is not set or
    /// holds a different branch.
    pub fn requested_run_time(&self) -> std::option::Option<&std::boxed::Box<wkt::Timestamp>> {
        #[allow(unreachable_patterns)]
        self.time.as_ref().and_then(|v| match v {
            crate::model::start_manual_transfer_runs_request::Time::RequestedRunTime(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [time][crate::model::StartManualTransferRunsRequest::time]
    /// to hold a `RequestedRunTime`.
    ///
    /// Note that all the setters affecting `time` are
    /// mutually exclusive.
    pub fn set_requested_run_time<T: std::convert::Into<std::boxed::Box<wkt::Timestamp>>>(
        mut self,
        v: T,
    ) -> Self {
        self.time = std::option::Option::Some(
            crate::model::start_manual_transfer_runs_request::Time::RequestedRunTime(v.into()),
        );
        self
    }
}

impl wkt::message::Message for StartManualTransferRunsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.StartManualTransferRunsRequest"
    }
}

/// Defines additional types related to [StartManualTransferRunsRequest].
pub mod start_manual_transfer_runs_request {
    #[allow(unused_imports)]
    use super::*;

    /// A specification for a time range, this will request transfer runs with
    /// run_time between start_time (inclusive) and end_time (exclusive).
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct TimeRange {
        /// Start time of the range of transfer runs. For example,
        /// `"2017-05-25T00:00:00+00:00"`. The start_time must be strictly less than
        /// the end_time. Creates transfer runs where run_time is in the range
        /// between start_time (inclusive) and end_time (exclusive).
        pub start_time: std::option::Option<wkt::Timestamp>,

        /// End time of the range of transfer runs. For example,
        /// `"2017-05-30T00:00:00+00:00"`. The end_time must not be in the future.
        /// Creates transfer runs where run_time is in the range between start_time
        /// (inclusive) and end_time (exclusive).
        pub end_time: std::option::Option<wkt::Timestamp>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl TimeRange {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [start_time][crate::model::start_manual_transfer_runs_request::TimeRange::start_time].
        pub fn set_start_time<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.start_time = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [start_time][crate::model::start_manual_transfer_runs_request::TimeRange::start_time].
        pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.start_time = v.map(|x| x.into());
            self
        }

        /// Sets the value of [end_time][crate::model::start_manual_transfer_runs_request::TimeRange::end_time].
        pub fn set_end_time<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.end_time = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [end_time][crate::model::start_manual_transfer_runs_request::TimeRange::end_time].
        pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.end_time = v.map(|x| x.into());
            self
        }
    }

    impl wkt::message::Message for TimeRange {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.StartManualTransferRunsRequest.TimeRange"
        }
    }

    /// The requested time specification - this can be a time range or a specific
    /// run_time.
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Time {
        /// A time_range start and end timestamp for historical data files or reports
        /// that are scheduled to be transferred by the scheduled transfer run.
        /// requested_time_range must be a past time and cannot include future time
        /// values.
        RequestedTimeRange(
            std::boxed::Box<crate::model::start_manual_transfer_runs_request::TimeRange>,
        ),
        /// A run_time timestamp for historical data files or reports
        /// that are scheduled to be transferred by the scheduled transfer run.
        /// requested_run_time must be a past time and cannot include future time
        /// values.
        RequestedRunTime(std::boxed::Box<wkt::Timestamp>),
    }
}

/// A response to start manual transfer runs.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct StartManualTransferRunsResponse {
    /// The transfer runs that were created.
    pub runs: std::vec::Vec<crate::model::TransferRun>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl StartManualTransferRunsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [runs][crate::model::StartManualTransferRunsResponse::runs].
    pub fn set_runs<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::TransferRun>,
    {
        use std::iter::Iterator;
        self.runs = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for StartManualTransferRunsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.StartManualTransferRunsResponse"
    }
}

/// A request to enroll a set of data sources so they are visible in the
/// BigQuery UI's `Transfer` tab.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct EnrollDataSourcesRequest {
    /// Required. The name of the project resource in the form:
    /// `projects/{project_id}`
    pub name: std::string::String,

    /// Data sources that are enrolled. It is required to provide at least one
    /// data source id.
    pub data_source_ids: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl EnrollDataSourcesRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::EnrollDataSourcesRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [data_source_ids][crate::model::EnrollDataSourcesRequest::data_source_ids].
    pub fn set_data_source_ids<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.data_source_ids = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for EnrollDataSourcesRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.EnrollDataSourcesRequest"
    }
}

/// A request to unenroll a set of data sources so they are no longer visible in
/// the BigQuery UI's `Transfer` tab.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UnenrollDataSourcesRequest {
    /// Required. The name of the project resource in the form:
    /// `projects/{project_id}`
    pub name: std::string::String,

    /// Data sources that are unenrolled. It is required to provide at least one
    /// data source id.
    pub data_source_ids: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UnenrollDataSourcesRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::UnenrollDataSourcesRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [data_source_ids][crate::model::UnenrollDataSourcesRequest::data_source_ids].
    pub fn set_data_source_ids<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.data_source_ids = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for UnenrollDataSourcesRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.UnenrollDataSourcesRequest"
    }
}

/// Represents preferences for sending email notifications for transfer run
/// events.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct EmailPreferences {
    /// If true, email notifications will be sent on transfer run failures.
    pub enable_failure_email: bool,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl EmailPreferences {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [enable_failure_email][crate::model::EmailPreferences::enable_failure_email].
    pub fn set_enable_failure_email<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.enable_failure_email = v.into();
        self
    }
}

impl wkt::message::Message for EmailPreferences {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.EmailPreferences"
    }
}

/// Options customizing the data transfer schedule.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ScheduleOptions {
    /// If true, automatic scheduling of data transfer runs for this configuration
    /// will be disabled. The runs can be started on ad-hoc basis using
    /// StartManualTransferRuns API. When automatic scheduling is disabled, the
    /// TransferConfig.schedule field will be ignored.
    pub disable_auto_scheduling: bool,

    /// Specifies time to start scheduling transfer runs. The first run will be
    /// scheduled at or after the start time according to a recurrence pattern
    /// defined in the schedule string. The start time can be changed at any
    /// moment. The time when a data transfer can be triggered manually is not
    /// limited by this option.
    pub start_time: std::option::Option<wkt::Timestamp>,

    /// Defines time to stop scheduling transfer runs. A transfer run cannot be
    /// scheduled at or after the end time. The end time can be changed at any
    /// moment. The time when a data transfer can be triggered manually is not
    /// limited by this option.
    pub end_time: std::option::Option<wkt::Timestamp>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ScheduleOptions {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [disable_auto_scheduling][crate::model::ScheduleOptions::disable_auto_scheduling].
    pub fn set_disable_auto_scheduling<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.disable_auto_scheduling = v.into();
        self
    }

    /// Sets the value of [start_time][crate::model::ScheduleOptions::start_time].
    pub fn set_start_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.start_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [start_time][crate::model::ScheduleOptions::start_time].
    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.start_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [end_time][crate::model::ScheduleOptions::end_time].
    pub fn set_end_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [end_time][crate::model::ScheduleOptions::end_time].
    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for ScheduleOptions {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.ScheduleOptions"
    }
}

/// V2 options customizing different types of data transfer schedule.
/// This field supports existing time-based and manual transfer schedule. Also
/// supports Event-Driven transfer schedule. ScheduleOptionsV2 cannot be used
/// together with ScheduleOptions/Schedule.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ScheduleOptionsV2 {
    /// Data transfer schedules.
    pub schedule: std::option::Option<crate::model::schedule_options_v_2::Schedule>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ScheduleOptionsV2 {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [schedule][crate::model::ScheduleOptionsV2::schedule].
    ///
    /// Note that all the setters affecting `schedule` are mutually
    /// exclusive.
    pub fn set_schedule<
        T: std::convert::Into<std::option::Option<crate::model::schedule_options_v_2::Schedule>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.schedule = v.into();
        self
    }

    /// The value of [schedule][crate::model::ScheduleOptionsV2::schedule]
    /// if it holds a `TimeBasedSchedule`, `None` if the field is not set or
    /// holds a different branch.
    pub fn time_based_schedule(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::TimeBasedSchedule>> {
        #[allow(unreachable_patterns)]
        self.schedule.as_ref().and_then(|v| match v {
            crate::model::schedule_options_v_2::Schedule::TimeBasedSchedule(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [schedule][crate::model::ScheduleOptionsV2::schedule]
    /// to hold a `TimeBasedSchedule`.
    ///
    /// Note that all the setters affecting `schedule` are
    /// mutually exclusive.
    pub fn set_time_based_schedule<
        T: std::convert::Into<std::boxed::Box<crate::model::TimeBasedSchedule>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.schedule = std::option::Option::Some(
            crate::model::schedule_options_v_2::Schedule::TimeBasedSchedule(v.into()),
        );
        self
    }

    /// The value of [schedule][crate::model::ScheduleOptionsV2::schedule]
    /// if it holds a `ManualSchedule`, `None` if the field is not set or
    /// holds a different branch.
    pub fn manual_schedule(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::ManualSchedule>> {
        #[allow(unreachable_patterns)]
        self.schedule.as_ref().and_then(|v| match v {
            crate::model::schedule_options_v_2::Schedule::ManualSchedule(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [schedule][crate::model::ScheduleOptionsV2::schedule]
    /// to hold a `ManualSchedule`.
    ///
    /// Note that all the setters affecting `schedule` are
    /// mutually exclusive.
    pub fn set_manual_schedule<
        T: std::convert::Into<std::boxed::Box<crate::model::ManualSchedule>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.schedule = std::option::Option::Some(
            crate::model::schedule_options_v_2::Schedule::ManualSchedule(v.into()),
        );
        self
    }

    /// The value of [schedule][crate::model::ScheduleOptionsV2::schedule]
    /// if it holds a `EventDrivenSchedule`, `None` if the field is not set or
    /// holds a different branch.
    pub fn event_driven_schedule(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::EventDrivenSchedule>> {
        #[allow(unreachable_patterns)]
        self.schedule.as_ref().and_then(|v| match v {
            crate::model::schedule_options_v_2::Schedule::EventDrivenSchedule(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [schedule][crate::model::ScheduleOptionsV2::schedule]
    /// to hold a `EventDrivenSchedule`.
    ///
    /// Note that all the setters affecting `schedule` are
    /// mutually exclusive.
    pub fn set_event_driven_schedule<
        T: std::convert::Into<std::boxed::Box<crate::model::EventDrivenSchedule>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.schedule = std::option::Option::Some(
            crate::model::schedule_options_v_2::Schedule::EventDrivenSchedule(v.into()),
        );
        self
    }
}

impl wkt::message::Message for ScheduleOptionsV2 {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.ScheduleOptionsV2"
    }
}

/// Defines additional types related to [ScheduleOptionsV2].
pub mod schedule_options_v_2 {
    #[allow(unused_imports)]
    use super::*;

    /// Data transfer schedules.
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Schedule {
        /// Time based transfer schedule options. This is the default schedule
        /// option.
        TimeBasedSchedule(std::boxed::Box<crate::model::TimeBasedSchedule>),
        /// Manual transfer schedule. If set, the transfer run will not be
        /// auto-scheduled by the system, unless the client invokes
        /// StartManualTransferRuns.  This is equivalent to
        /// disable_auto_scheduling = true.
        ManualSchedule(std::boxed::Box<crate::model::ManualSchedule>),
        /// Event driven transfer schedule options. If set, the transfer will be
        /// scheduled upon events arrial.
        EventDrivenSchedule(std::boxed::Box<crate::model::EventDrivenSchedule>),
    }
}

/// Options customizing the time based transfer schedule.
/// Options are migrated from the original ScheduleOptions message.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct TimeBasedSchedule {
    /// Data transfer schedule.
    /// If the data source does not support a custom schedule, this should be
    /// empty. If it is empty, the default value for the data source will be used.
    /// The specified times are in UTC.
    /// Examples of valid format:
    /// `1st,3rd monday of month 15:30`,
    /// `every wed,fri of jan,jun 13:15`, and
    /// `first sunday of quarter 00:00`.
    /// See more explanation about the format here:
    /// <https://cloud.google.com/appengine/docs/flexible/python/scheduling-jobs-with-cron-yaml#the_schedule_format>
    ///
    /// NOTE: The minimum interval time between recurring transfers depends on the
    /// data source; refer to the documentation for your data source.
    pub schedule: std::string::String,

    /// Specifies time to start scheduling transfer runs. The first run will be
    /// scheduled at or after the start time according to a recurrence pattern
    /// defined in the schedule string. The start time can be changed at any
    /// moment.
    pub start_time: std::option::Option<wkt::Timestamp>,

    /// Defines time to stop scheduling transfer runs. A transfer run cannot be
    /// scheduled at or after the end time. The end time can be changed at any
    /// moment.
    pub end_time: std::option::Option<wkt::Timestamp>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl TimeBasedSchedule {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [schedule][crate::model::TimeBasedSchedule::schedule].
    pub fn set_schedule<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.schedule = v.into();
        self
    }

    /// Sets the value of [start_time][crate::model::TimeBasedSchedule::start_time].
    pub fn set_start_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.start_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [start_time][crate::model::TimeBasedSchedule::start_time].
    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.start_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [end_time][crate::model::TimeBasedSchedule::end_time].
    pub fn set_end_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [end_time][crate::model::TimeBasedSchedule::end_time].
    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for TimeBasedSchedule {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.TimeBasedSchedule"
    }
}

/// Options customizing manual transfers schedule.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ManualSchedule {
    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ManualSchedule {
    pub fn new() -> Self {
        std::default::Default::default()
    }
}

impl wkt::message::Message for ManualSchedule {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.ManualSchedule"
    }
}

/// Options customizing EventDriven transfers schedule.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct EventDrivenSchedule {
    /// Pub/Sub subscription name used to receive events.
    /// Only Google Cloud Storage data source support this option.
    /// Format: projects/{project}/subscriptions/{subscription}
    pub pubsub_subscription: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl EventDrivenSchedule {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [pubsub_subscription][crate::model::EventDrivenSchedule::pubsub_subscription].
    pub fn set_pubsub_subscription<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.pubsub_subscription = v.into();
        self
    }
}

impl wkt::message::Message for EventDrivenSchedule {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.EventDrivenSchedule"
    }
}

/// Information about a user.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UserInfo {
    /// E-mail address of the user.
    pub email: std::option::Option<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UserInfo {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [email][crate::model::UserInfo::email].
    pub fn set_email<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<std::string::String>,
    {
        self.email = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [email][crate::model::UserInfo::email].
    pub fn set_or_clear_email<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<std::string::String>,
    {
        self.email = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for UserInfo {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.UserInfo"
    }
}

/// Represents a data transfer configuration. A transfer configuration
/// contains all metadata needed to perform a data transfer. For example,
/// `destination_dataset_id` specifies where data should be stored.
/// When a new transfer configuration is created, the specified
/// `destination_dataset_id` is created when needed and shared with the
/// appropriate data source service account.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct TransferConfig {
    /// Identifier. The resource name of the transfer config.
    /// Transfer config names have the form either
    /// `projects/{project_id}/locations/{region}/transferConfigs/{config_id}` or
    /// `projects/{project_id}/transferConfigs/{config_id}`,
    /// where `config_id` is usually a UUID, even though it is not
    /// guaranteed or required. The name is ignored when creating a transfer
    /// config.
    pub name: std::string::String,

    /// User specified display name for the data transfer.
    pub display_name: std::string::String,

    /// Data source ID. This cannot be changed once data transfer is created. The
    /// full list of available data source IDs can be returned through an API call:
    /// <https://cloud.google.com/bigquery-transfer/docs/reference/datatransfer/rest/v1/projects.locations.dataSources/list>
    pub data_source_id: std::string::String,

    /// Parameters specific to each data source. For more information see the
    /// bq tab in the 'Setting up a data transfer' section for each data source.
    /// For example the parameters for Cloud Storage transfers are listed here:
    /// <https://cloud.google.com/bigquery-transfer/docs/cloud-storage-transfer#bq>
    pub params: std::option::Option<wkt::Struct>,

    /// Data transfer schedule.
    /// If the data source does not support a custom schedule, this should be
    /// empty. If it is empty, the default value for the data source will be used.
    /// The specified times are in UTC.
    /// Examples of valid format:
    /// `1st,3rd monday of month 15:30`,
    /// `every wed,fri of jan,jun 13:15`, and
    /// `first sunday of quarter 00:00`.
    /// See more explanation about the format here:
    /// <https://cloud.google.com/appengine/docs/flexible/python/scheduling-jobs-with-cron-yaml#the_schedule_format>
    ///
    /// NOTE: The minimum interval time between recurring transfers depends on the
    /// data source; refer to the documentation for your data source.
    pub schedule: std::string::String,

    /// Options customizing the data transfer schedule.
    pub schedule_options: std::option::Option<crate::model::ScheduleOptions>,

    /// Options customizing different types of data transfer schedule.
    /// This field replaces "schedule" and "schedule_options" fields.
    /// ScheduleOptionsV2 cannot be used together with ScheduleOptions/Schedule.
    pub schedule_options_v2: std::option::Option<crate::model::ScheduleOptionsV2>,

    /// The number of days to look back to automatically refresh the data.
    /// For example, if `data_refresh_window_days = 10`, then every day
    /// BigQuery reingests data for [today-10, today-1], rather than ingesting data
    /// for just [today-1].
    /// Only valid if the data source supports the feature. Set the value to 0
    /// to use the default value.
    pub data_refresh_window_days: i32,

    /// Is this config disabled. When set to true, no runs will be scheduled for
    /// this transfer config.
    pub disabled: bool,

    /// Output only. Data transfer modification time. Ignored by server on input.
    pub update_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Next time when data transfer will run.
    pub next_run_time: std::option::Option<wkt::Timestamp>,

    /// Output only. State of the most recently updated transfer run.
    pub state: crate::model::TransferState,

    /// Deprecated. Unique ID of the user on whose behalf transfer is done.
    pub user_id: i64,

    /// Output only. Region in which BigQuery dataset is located.
    pub dataset_region: std::string::String,

    /// Pub/Sub topic where notifications will be sent after transfer runs
    /// associated with this transfer config finish.
    ///
    /// The format for specifying a pubsub topic is:
    /// `projects/{project_id}/topics/{topic_id}`
    pub notification_pubsub_topic: std::string::String,

    /// Email notifications will be sent according to these preferences
    /// to the email address of the user who owns this transfer config.
    pub email_preferences: std::option::Option<crate::model::EmailPreferences>,

    /// Output only. Information about the user whose credentials are used to
    /// transfer data. Populated only for `transferConfigs.get` requests. In case
    /// the user information is not available, this field will not be populated.
    pub owner_info: std::option::Option<crate::model::UserInfo>,

    /// The encryption configuration part. Currently, it is only used for the
    /// optional KMS key name. The BigQuery service account of your project must be
    /// granted permissions to use the key. Read methods will return the key name
    /// applied in effect. Write methods will apply the key if it is present, or
    /// otherwise try to apply project default keys if it is absent.
    pub encryption_configuration: std::option::Option<crate::model::EncryptionConfiguration>,

    /// Output only. Error code with detailed information about reason of the
    /// latest config failure.
    pub error: std::option::Option<rpc::model::Status>,

    /// The desination of the transfer config.
    pub destination: std::option::Option<crate::model::transfer_config::Destination>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl TransferConfig {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::TransferConfig::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [display_name][crate::model::TransferConfig::display_name].
    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.display_name = v.into();
        self
    }

    /// Sets the value of [data_source_id][crate::model::TransferConfig::data_source_id].
    pub fn set_data_source_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.data_source_id = v.into();
        self
    }

    /// Sets the value of [params][crate::model::TransferConfig::params].
    pub fn set_params<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Struct>,
    {
        self.params = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [params][crate::model::TransferConfig::params].
    pub fn set_or_clear_params<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Struct>,
    {
        self.params = v.map(|x| x.into());
        self
    }

    /// Sets the value of [schedule][crate::model::TransferConfig::schedule].
    pub fn set_schedule<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.schedule = v.into();
        self
    }

    /// Sets the value of [schedule_options][crate::model::TransferConfig::schedule_options].
    pub fn set_schedule_options<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::ScheduleOptions>,
    {
        self.schedule_options = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [schedule_options][crate::model::TransferConfig::schedule_options].
    pub fn set_or_clear_schedule_options<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::ScheduleOptions>,
    {
        self.schedule_options = v.map(|x| x.into());
        self
    }

    /// Sets the value of [schedule_options_v2][crate::model::TransferConfig::schedule_options_v2].
    pub fn set_schedule_options_v2<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::ScheduleOptionsV2>,
    {
        self.schedule_options_v2 = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [schedule_options_v2][crate::model::TransferConfig::schedule_options_v2].
    pub fn set_or_clear_schedule_options_v2<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::ScheduleOptionsV2>,
    {
        self.schedule_options_v2 = v.map(|x| x.into());
        self
    }

    /// Sets the value of [data_refresh_window_days][crate::model::TransferConfig::data_refresh_window_days].
    pub fn set_data_refresh_window_days<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.data_refresh_window_days = v.into();
        self
    }

    /// Sets the value of [disabled][crate::model::TransferConfig::disabled].
    pub fn set_disabled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.disabled = v.into();
        self
    }

    /// Sets the value of [update_time][crate::model::TransferConfig::update_time].
    pub fn set_update_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_time][crate::model::TransferConfig::update_time].
    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [next_run_time][crate::model::TransferConfig::next_run_time].
    pub fn set_next_run_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.next_run_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [next_run_time][crate::model::TransferConfig::next_run_time].
    pub fn set_or_clear_next_run_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.next_run_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [state][crate::model::TransferConfig::state].
    pub fn set_state<T: std::convert::Into<crate::model::TransferState>>(mut self, v: T) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [user_id][crate::model::TransferConfig::user_id].
    pub fn set_user_id<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.user_id = v.into();
        self
    }

    /// Sets the value of [dataset_region][crate::model::TransferConfig::dataset_region].
    pub fn set_dataset_region<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.dataset_region = v.into();
        self
    }

    /// Sets the value of [notification_pubsub_topic][crate::model::TransferConfig::notification_pubsub_topic].
    pub fn set_notification_pubsub_topic<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.notification_pubsub_topic = v.into();
        self
    }

    /// Sets the value of [email_preferences][crate::model::TransferConfig::email_preferences].
    pub fn set_email_preferences<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::EmailPreferences>,
    {
        self.email_preferences = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [email_preferences][crate::model::TransferConfig::email_preferences].
    pub fn set_or_clear_email_preferences<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::EmailPreferences>,
    {
        self.email_preferences = v.map(|x| x.into());
        self
    }

    /// Sets the value of [owner_info][crate::model::TransferConfig::owner_info].
    pub fn set_owner_info<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::UserInfo>,
    {
        self.owner_info = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [owner_info][crate::model::TransferConfig::owner_info].
    pub fn set_or_clear_owner_info<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::UserInfo>,
    {
        self.owner_info = v.map(|x| x.into());
        self
    }

    /// Sets the value of [encryption_configuration][crate::model::TransferConfig::encryption_configuration].
    pub fn set_encryption_configuration<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::EncryptionConfiguration>,
    {
        self.encryption_configuration = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [encryption_configuration][crate::model::TransferConfig::encryption_configuration].
    pub fn set_or_clear_encryption_configuration<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::EncryptionConfiguration>,
    {
        self.encryption_configuration = v.map(|x| x.into());
        self
    }

    /// Sets the value of [error][crate::model::TransferConfig::error].
    pub fn set_error<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<rpc::model::Status>,
    {
        self.error = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [error][crate::model::TransferConfig::error].
    pub fn set_or_clear_error<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<rpc::model::Status>,
    {
        self.error = v.map(|x| x.into());
        self
    }

    /// Sets the value of [destination][crate::model::TransferConfig::destination].
    ///
    /// Note that all the setters affecting `destination` are mutually
    /// exclusive.
    pub fn set_destination<
        T: std::convert::Into<std::option::Option<crate::model::transfer_config::Destination>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.destination = v.into();
        self
    }

    /// The value of [destination][crate::model::TransferConfig::destination]
    /// if it holds a `DestinationDatasetId`, `None` if the field is not set or
    /// holds a different branch.
    pub fn destination_dataset_id(&self) -> std::option::Option<&std::string::String> {
        #[allow(unreachable_patterns)]
        self.destination.as_ref().and_then(|v| match v {
            crate::model::transfer_config::Destination::DestinationDatasetId(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [destination][crate::model::TransferConfig::destination]
    /// to hold a `DestinationDatasetId`.
    ///
    /// Note that all the setters affecting `destination` are
    /// mutually exclusive.
    pub fn set_destination_dataset_id<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.destination = std::option::Option::Some(
            crate::model::transfer_config::Destination::DestinationDatasetId(v.into()),
        );
        self
    }
}

impl wkt::message::Message for TransferConfig {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.TransferConfig"
    }
}

/// Defines additional types related to [TransferConfig].
pub mod transfer_config {
    #[allow(unused_imports)]
    use super::*;

    /// The desination of the transfer config.
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Destination {
        /// The BigQuery target dataset id.
        DestinationDatasetId(std::string::String),
    }
}

/// Represents the encryption configuration for a transfer.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct EncryptionConfiguration {
    /// The name of the KMS key used for encrypting BigQuery data.
    pub kms_key_name: std::option::Option<wkt::StringValue>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl EncryptionConfiguration {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [kms_key_name][crate::model::EncryptionConfiguration::kms_key_name].
    pub fn set_kms_key_name<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::StringValue>,
    {
        self.kms_key_name = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [kms_key_name][crate::model::EncryptionConfiguration::kms_key_name].
    pub fn set_or_clear_kms_key_name<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::StringValue>,
    {
        self.kms_key_name = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for EncryptionConfiguration {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.EncryptionConfiguration"
    }
}

/// Represents a data transfer run.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct TransferRun {
    /// Identifier. The resource name of the transfer run.
    /// Transfer run names have the form
    /// `projects/{project_id}/locations/{location}/transferConfigs/{config_id}/runs/{run_id}`.
    /// The name is ignored when creating a transfer run.
    pub name: std::string::String,

    /// Minimum time after which a transfer run can be started.
    pub schedule_time: std::option::Option<wkt::Timestamp>,

    /// For batch transfer runs, specifies the date and time of the data should be
    /// ingested.
    pub run_time: std::option::Option<wkt::Timestamp>,

    /// Status of the transfer run.
    pub error_status: std::option::Option<rpc::model::Status>,

    /// Output only. Time when transfer run was started.
    /// Parameter ignored by server for input requests.
    pub start_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Time when transfer run ended.
    /// Parameter ignored by server for input requests.
    pub end_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Last time the data transfer run state was updated.
    pub update_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Parameters specific to each data source. For more information
    /// see the bq tab in the 'Setting up a data transfer' section for each data
    /// source. For example the parameters for Cloud Storage transfers are listed
    /// here:
    /// <https://cloud.google.com/bigquery-transfer/docs/cloud-storage-transfer#bq>
    pub params: std::option::Option<wkt::Struct>,

    /// Output only. Data source id.
    pub data_source_id: std::string::String,

    /// Data transfer run state. Ignored for input requests.
    pub state: crate::model::TransferState,

    /// Deprecated. Unique ID of the user on whose behalf transfer is done.
    pub user_id: i64,

    /// Output only. Describes the schedule of this transfer run if it was
    /// created as part of a regular schedule. For batch transfer runs that are
    /// scheduled manually, this is empty.
    /// NOTE: the system might choose to delay the schedule depending on the
    /// current load, so `schedule_time` doesn't always match this.
    pub schedule: std::string::String,

    /// Output only. Pub/Sub topic where a notification will be sent after this
    /// transfer run finishes.
    ///
    /// The format for specifying a pubsub topic is:
    /// `projects/{project_id}/topics/{topic_id}`
    pub notification_pubsub_topic: std::string::String,

    /// Output only. Email notifications will be sent according to these
    /// preferences to the email address of the user who owns the transfer config
    /// this run was derived from.
    pub email_preferences: std::option::Option<crate::model::EmailPreferences>,

    /// Data transfer destination.
    pub destination: std::option::Option<crate::model::transfer_run::Destination>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl TransferRun {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::TransferRun::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [schedule_time][crate::model::TransferRun::schedule_time].
    pub fn set_schedule_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.schedule_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [schedule_time][crate::model::TransferRun::schedule_time].
    pub fn set_or_clear_schedule_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.schedule_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [run_time][crate::model::TransferRun::run_time].
    pub fn set_run_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.run_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [run_time][crate::model::TransferRun::run_time].
    pub fn set_or_clear_run_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.run_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [error_status][crate::model::TransferRun::error_status].
    pub fn set_error_status<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<rpc::model::Status>,
    {
        self.error_status = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [error_status][crate::model::TransferRun::error_status].
    pub fn set_or_clear_error_status<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<rpc::model::Status>,
    {
        self.error_status = v.map(|x| x.into());
        self
    }

    /// Sets the value of [start_time][crate::model::TransferRun::start_time].
    pub fn set_start_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.start_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [start_time][crate::model::TransferRun::start_time].
    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.start_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [end_time][crate::model::TransferRun::end_time].
    pub fn set_end_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [end_time][crate::model::TransferRun::end_time].
    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [update_time][crate::model::TransferRun::update_time].
    pub fn set_update_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_time][crate::model::TransferRun::update_time].
    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [params][crate::model::TransferRun::params].
    pub fn set_params<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Struct>,
    {
        self.params = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [params][crate::model::TransferRun::params].
    pub fn set_or_clear_params<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Struct>,
    {
        self.params = v.map(|x| x.into());
        self
    }

    /// Sets the value of [data_source_id][crate::model::TransferRun::data_source_id].
    pub fn set_data_source_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.data_source_id = v.into();
        self
    }

    /// Sets the value of [state][crate::model::TransferRun::state].
    pub fn set_state<T: std::convert::Into<crate::model::TransferState>>(mut self, v: T) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [user_id][crate::model::TransferRun::user_id].
    pub fn set_user_id<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.user_id = v.into();
        self
    }

    /// Sets the value of [schedule][crate::model::TransferRun::schedule].
    pub fn set_schedule<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.schedule = v.into();
        self
    }

    /// Sets the value of [notification_pubsub_topic][crate::model::TransferRun::notification_pubsub_topic].
    pub fn set_notification_pubsub_topic<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.notification_pubsub_topic = v.into();
        self
    }

    /// Sets the value of [email_preferences][crate::model::TransferRun::email_preferences].
    pub fn set_email_preferences<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::EmailPreferences>,
    {
        self.email_preferences = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [email_preferences][crate::model::TransferRun::email_preferences].
    pub fn set_or_clear_email_preferences<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::EmailPreferences>,
    {
        self.email_preferences = v.map(|x| x.into());
        self
    }

    /// Sets the value of [destination][crate::model::TransferRun::destination].
    ///
    /// Note that all the setters affecting `destination` are mutually
    /// exclusive.
    pub fn set_destination<
        T: std::convert::Into<std::option::Option<crate::model::transfer_run::Destination>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.destination = v.into();
        self
    }

    /// The value of [destination][crate::model::TransferRun::destination]
    /// if it holds a `DestinationDatasetId`, `None` if the field is not set or
    /// holds a different branch.
    pub fn destination_dataset_id(&self) -> std::option::Option<&std::string::String> {
        #[allow(unreachable_patterns)]
        self.destination.as_ref().and_then(|v| match v {
            crate::model::transfer_run::Destination::DestinationDatasetId(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [destination][crate::model::TransferRun::destination]
    /// to hold a `DestinationDatasetId`.
    ///
    /// Note that all the setters affecting `destination` are
    /// mutually exclusive.
    pub fn set_destination_dataset_id<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.destination = std::option::Option::Some(
            crate::model::transfer_run::Destination::DestinationDatasetId(v.into()),
        );
        self
    }
}

impl wkt::message::Message for TransferRun {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.TransferRun"
    }
}

/// Defines additional types related to [TransferRun].
pub mod transfer_run {
    #[allow(unused_imports)]
    use super::*;

    /// Data transfer destination.
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Destination {
        /// Output only. The BigQuery target dataset id.
        DestinationDatasetId(std::string::String),
    }
}

/// Represents a user facing message for a particular data transfer run.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct TransferMessage {
    /// Time when message was logged.
    pub message_time: std::option::Option<wkt::Timestamp>,

    /// Message severity.
    pub severity: crate::model::transfer_message::MessageSeverity,

    /// Message text.
    pub message_text: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl TransferMessage {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [message_time][crate::model::TransferMessage::message_time].
    pub fn set_message_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.message_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [message_time][crate::model::TransferMessage::message_time].
    pub fn set_or_clear_message_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.message_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [severity][crate::model::TransferMessage::severity].
    pub fn set_severity<T: std::convert::Into<crate::model::transfer_message::MessageSeverity>>(
        mut self,
        v: T,
    ) -> Self {
        self.severity = v.into();
        self
    }

    /// Sets the value of [message_text][crate::model::TransferMessage::message_text].
    pub fn set_message_text<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.message_text = v.into();
        self
    }
}

impl wkt::message::Message for TransferMessage {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.bigquery.datatransfer.v1.TransferMessage"
    }
}

/// Defines additional types related to [TransferMessage].
pub mod transfer_message {
    #[allow(unused_imports)]
    use super::*;

    /// Represents data transfer user facing message severity.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum MessageSeverity {
        /// No severity specified.
        Unspecified,
        /// Informational message.
        Info,
        /// Warning message.
        Warning,
        /// Error message.
        Error,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [MessageSeverity::value] or
        /// [MessageSeverity::name].
        UnknownValue(message_severity::UnknownValue),
    }

    #[doc(hidden)]
    pub mod message_severity {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl MessageSeverity {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Info => std::option::Option::Some(1),
                Self::Warning => std::option::Option::Some(2),
                Self::Error => std::option::Option::Some(3),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("MESSAGE_SEVERITY_UNSPECIFIED"),
                Self::Info => std::option::Option::Some("INFO"),
                Self::Warning => std::option::Option::Some("WARNING"),
                Self::Error => std::option::Option::Some("ERROR"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for MessageSeverity {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for MessageSeverity {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for MessageSeverity {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Info,
                2 => Self::Warning,
                3 => Self::Error,
                _ => Self::UnknownValue(message_severity::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for MessageSeverity {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "MESSAGE_SEVERITY_UNSPECIFIED" => Self::Unspecified,
                "INFO" => Self::Info,
                "WARNING" => Self::Warning,
                "ERROR" => Self::Error,
                _ => Self::UnknownValue(message_severity::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for MessageSeverity {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Info => serializer.serialize_i32(1),
                Self::Warning => serializer.serialize_i32(2),
                Self::Error => serializer.serialize_i32(3),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for MessageSeverity {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<MessageSeverity>::new(
                ".google.cloud.bigquery.datatransfer.v1.TransferMessage.MessageSeverity",
            ))
        }
    }
}

/// DEPRECATED. Represents data transfer type.
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
#[deprecated]
pub enum TransferType {
    /// Invalid or Unknown transfer type placeholder.
    Unspecified,
    /// Batch data transfer.
    Batch,
    /// Streaming data transfer. Streaming data source currently doesn't
    /// support multiple transfer configs per project.
    Streaming,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [TransferType::value] or
    /// [TransferType::name].
    UnknownValue(transfer_type::UnknownValue),
}

#[doc(hidden)]
pub mod transfer_type {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl TransferType {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::Batch => std::option::Option::Some(1),
            Self::Streaming => std::option::Option::Some(2),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => std::option::Option::Some("TRANSFER_TYPE_UNSPECIFIED"),
            Self::Batch => std::option::Option::Some("BATCH"),
            Self::Streaming => std::option::Option::Some("STREAMING"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for TransferType {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for TransferType {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for TransferType {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            1 => Self::Batch,
            2 => Self::Streaming,
            _ => Self::UnknownValue(transfer_type::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for TransferType {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "TRANSFER_TYPE_UNSPECIFIED" => Self::Unspecified,
            "BATCH" => Self::Batch,
            "STREAMING" => Self::Streaming,
            _ => Self::UnknownValue(transfer_type::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for TransferType {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::Batch => serializer.serialize_i32(1),
            Self::Streaming => serializer.serialize_i32(2),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for TransferType {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<TransferType>::new(
            ".google.cloud.bigquery.datatransfer.v1.TransferType",
        ))
    }
}

/// Represents data transfer run state.
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum TransferState {
    /// State placeholder (0).
    Unspecified,
    /// Data transfer is scheduled and is waiting to be picked up by
    /// data transfer backend (2).
    Pending,
    /// Data transfer is in progress (3).
    Running,
    /// Data transfer completed successfully (4).
    Succeeded,
    /// Data transfer failed (5).
    Failed,
    /// Data transfer is cancelled (6).
    Cancelled,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [TransferState::value] or
    /// [TransferState::name].
    UnknownValue(transfer_state::UnknownValue),
}

#[doc(hidden)]
pub mod transfer_state {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl TransferState {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::Pending => std::option::Option::Some(2),
            Self::Running => std::option::Option::Some(3),
            Self::Succeeded => std::option::Option::Some(4),
            Self::Failed => std::option::Option::Some(5),
            Self::Cancelled => std::option::Option::Some(6),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => std::option::Option::Some("TRANSFER_STATE_UNSPECIFIED"),
            Self::Pending => std::option::Option::Some("PENDING"),
            Self::Running => std::option::Option::Some("RUNNING"),
            Self::Succeeded => std::option::Option::Some("SUCCEEDED"),
            Self::Failed => std::option::Option::Some("FAILED"),
            Self::Cancelled => std::option::Option::Some("CANCELLED"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for TransferState {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for TransferState {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for TransferState {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            2 => Self::Pending,
            3 => Self::Running,
            4 => Self::Succeeded,
            5 => Self::Failed,
            6 => Self::Cancelled,
            _ => Self::UnknownValue(transfer_state::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for TransferState {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "TRANSFER_STATE_UNSPECIFIED" => Self::Unspecified,
            "PENDING" => Self::Pending,
            "RUNNING" => Self::Running,
            "SUCCEEDED" => Self::Succeeded,
            "FAILED" => Self::Failed,
            "CANCELLED" => Self::Cancelled,
            _ => Self::UnknownValue(transfer_state::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for TransferState {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::Pending => serializer.serialize_i32(2),
            Self::Running => serializer.serialize_i32(3),
            Self::Succeeded => serializer.serialize_i32(4),
            Self::Failed => serializer.serialize_i32(5),
            Self::Cancelled => serializer.serialize_i32(6),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for TransferState {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<TransferState>::new(
            ".google.cloud.bigquery.datatransfer.v1.TransferState",
        ))
    }
}
